﻿using System.Windows.Forms;
using System.Collections;
using System;
namespace Mota.XMLControls
{
    public abstract class GuiDictionaryDecorator:GuiControl,IDatasourceObject
    {
        protected  GuiControl decoratedControl = null;

        public override void Add(GuiControl guiControl)
        {
            if(decoratedControl!=null)
            {
                decoratedControl.Add(guiControl);
            }
        }

        public override IEnumerator GetEnumerator()
        {
            if (decoratedControl != null)
            {
               return decoratedControl.GetEnumerator();
            }
            return null;
        }


        public override void Accept(GuiVisitor visitor)
        {
            if (decoratedControl != null)
            {
                decoratedControl.Accept(visitor);
            }
        }
        public override void SetPropertyValue(String properyName, String propertyValue)
        {
            base.SetPropertyValue(properyName, propertyValue);
            switch(properyName)
            {
                case "Text":
                case "Dock":
                    break;
                default:
                    decoratedControl.SetPropertyValue(properyName, propertyValue);
                break;
            }
            
            
        }



        #region IDatasourceObject Members

        public abstract bool UseOnlyActive { get; set; }

        public abstract bool UseGroupBy { get; set; }

        public abstract bool IsEditable{get;set;}

        public abstract void Refresh(EditModule.ConnectionConfigs configs, BindingSource mainBs);

        #endregion
    }
}
